package com.yootk.action.muyan;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.sql.DataSource;

@Slf4j
@RestController
@RequestMapping("/dept/*")
public class DeptAction {

    @Autowired
    private DataSource dataSource;  // 应该根据当前的程序包自动的切换

    // 获取数据源信息
    @RequestMapping("datasource")
    public Object getDataSource() throws Exception {
        log.info("【MUYAN】数据源：{}", dataSource);
        return dataSource.getConnection().getCatalog();
    }
}
